package org.krinko.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.krinko.entity.UmsSysUser;
import org.krinko.response.DaoCaoResult;
import org.krinko.service.IUmsSysUserService;
import org.springframework.web.bind.annotation.*;


import java.util.List;

@RestController

@RequestMapping("ums/sysuser")
public class UmsSysController {

    @Resource
    private IUmsSysUserService service;

    /**
     * 添加用户接口
     * @return 统一响应接口
     */
    @PostMapping
    public DaoCaoResult addSysUser(@RequestBody UmsSysUser user){
        boolean flag = service.save(user);
        if(flag){
            return DaoCaoResult.success("新增用户成功");
        }
        return DaoCaoResult.error("新增用户失败");
    }
    /**
     * 获取全部用户列表接口
     */
    @GetMapping
    public DaoCaoResult searchList(){
        List<UmsSysUser> list = service.list();
        list.forEach(System.out::println);
        return DaoCaoResult.success(list);
    }
}
